#include "stdafx.h"
#include "Field.h"


Field::Field()
	: length_(0), notNull_(false)
{
}

Field::Field(const std::string &name)
	: name_(name), length_(0), notNull_(false)
{
}

Field:: Field(const std::string &name, const std::string &type, int length, bool notNull, const std::string &defaultValue, const std::string &key, const std::string &extra)
{
	name_ = name;

	type_ = type;

	length_ = length;

	notNull_ = notNull;

	defaultValue_ = defaultValue;

	key_ = key;

	extra_ = extra;
}

Field::Field(const Field & from)
{
	name_ = from.name_;

	type_ = from.type_;

	length_ = from.length_;

	notNull_ = from.notNull_;

	defaultValue_ = from.defaultValue_;

	key_ = from.key_;

	extra_ = from.extra_;
}

Field::~Field()
{
}

Field & Field::operator=(const Field & from)
{
	name_ = from.name_;

	type_ = from.type_;

	length_ = from.length_;

	notNull_ = from.notNull_;

	defaultValue_ = from.defaultValue_;

	key_ = from.key_;

	extra_ = from.extra_;

	return *this;
}

void Field::load(tinyxml2::XMLElement * element)
{
	if (element == nullptr)
	{
		return;
	}

	const char *name = element->Attribute("name");
	if (name)
	{
		name_ = name;
	}
}
